<?php

/*
 * 任务类型类
 * and open the template in the editor.
 */

namespace app\admin\controller;
use app\common\controller\Backend;
/**
 * Description of Tasktype
 *
 * @author Administrator
 */
class Tasktype extends Backend{
    
      protected $model = null;

    public function _initialize() {
        parent::_initialize();
        $this->model = model('Tasktype');
    }
    /*
     * 任务类型列表
     * */
    public function index() {

        $this->request->filter(['strip_tags']);
        if ($this->request->isAjax()) {
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('pkey_name')) {
                return $this->selectpage();
            }
            $task = $this->model;
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $total = $task
                    ->where($where)
                    ->order($sort, $order)
                    ->count();
            $list = $task
                    ->where($where)
                    ->order($sort, $order)
                    ->limit($offset, $limit)
                    ->select();
            $result = array("total" => $total, "rows" => $list);
            return json($result);
        }
        return $this->fetch();
    }
    /*
     * 删除
     */
    public function del($ids = '')
    {
       $ids = $this->request->param('ids');
        $row = $this->model->where('id',$ids)->update(['status'=>'-1']);
        if($row)
        {
             $this->success();
        }
        else
        {
             $this->error('失败请重试');
        }
 
        return $this->view->fetch();
    }
    
    
}
